package com.yic.module.infra.api.job;

import com.yic.module.infra.api.job.dto.JobApiDTO;
import com.yic.module.infra.controller.admin.job.vo.job.JobCreateReqVO;
import com.yic.module.infra.convert.job.JobConvert;
import com.yic.module.infra.service.job.JobService;
import org.quartz.SchedulerException;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * @Description 定时任务 API接口
 * @Author liuzhi
 * @Date 2023/12/15
 * @Version 1.0
 */
@Service
@Validated
public class JobImpl implements JobApi{
    @Resource
    private JobService jobService;
    @Override
    public Long createJob(JobApiDTO jobApiDTO) throws SchedulerException {
        JobCreateReqVO jobCreateReqVO  = JobConvert.INSTANCE.convert01(jobApiDTO);
        return jobService.createJob(jobCreateReqVO);
    }

    @Override
    public void deleteJob(Long jobId) throws Exception {
        jobService.deleteJob(jobId);
    }
}
